<?php
/**
 * User:于小涛
 * Date:2020/2/18
 * Time:16:31
 */
namespace app\admin\business\system;
use app\admin\model\system\Config as ConfigModel;
use think\db\concern\Model;

class Config{
    private $arr_key=[
        'home_data'=>'home_data',
    ];
    private $obj_config_model=null;
    public function __construct()
    {
        $this->obj_config_model = new ConfigModel();
    }

    public function updateHomeData($arr_home_data){
        $arr_edit_data=[
            'content'=>json_encode($arr_home_data)
        ];
        $int_num=$this->obj_config_model->editByKey($this->arr_key['home_data'],$arr_edit_data);
        if($int_num){
            trace("修改首页数据成功");
            return ['ret'=>0,'reason'=>'success'];
        }else{
            trace("修改首页数据失败",'error');
            return ['ret'=>1,'reason'=>'修改失败'];
        }
    }

    public function getHomeData(){
        $arr_info=$this->obj_config_model->where("key",$this->arr_key['home_data'])->findOrEmpty()->toArray();
        return [
            'ret'=>0,
            'reason'=>'success',
            'data'=>$arr_info
        ];
    }

}